package sword_offer;

/**
 * @author Synhard
 * @version 1.0
 * @Class sword_offer.Code27
 * @Description 请完成一个函数，输入一个二叉树，该函数输出它的镜像。
 * @tel 13001321080
 * @email 823436512@qq.com
 * @date 2021-03-17 14:58
 */
public class Code27 {
    public TreeNode mirrorTree(TreeNode root) {
        return format(root);
    }
    public TreeNode format(TreeNode root) {
        TreeNode temp = new TreeNode(0);
        if (root != null) {
            temp = root.left;
            root.left = root.right;
            root.right = temp;
            format(root.left);
            format(root.right);
        }
        return root;
    }
}
